<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>粉丝列表</title>
		<link rel="stylesheet" href="/dvmini/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/dvmini/res/css/basic.css">
	</head>

	<body class="wrap">
		<form class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
				<div class="layui-input-inline" style="width: 150px;">
					<input class="layui-input" name="keyword" placeholder="关键字" />
				</div>
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary" lay-submit lay-filter="resetbtn">重置</button>
			</div>		
		</form>
		<table class="layui-table">
			<thead>
				<tr>
					<th style="width:30px;">No</th>
					<th style="min-width:120px;">头像昵称</th>
					<th style="min-width:80px;">上级粉丝</th>
					<th style="min-width:60px;">销售人员</th>
					<th style="min-width:60px;">小程序 openid</th>
					<th style="min-width:80px;">创建时间</th>
					<th style="min-width:80px;">上次登录时间</th>
				</tr>
			</thead>
			<tbody id="fanslist">
				
			</tbody>
		</table>
		<div class="nulldata">暂无数据</div>
		<div id="page"></div>
		
	</body>
	<script src='/dvmini/res/js/jquery.min.js'></script>
	<script src="/dvmini/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/dvmini/res/js/me.js"></script>
	<script>
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
			var form = layui.form(),
				element = layui.element(),
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
				
			var page = 1,keyword = ""
			
			//初始化数据
			initData(page, keyword)
			
			function initData(page, keyword){
				$.post("/dvmini/report/getFansList",{page:page,keyword:keyword},function(data){
					console.log(data)
					data=data.data;
					
					laypage({
						cont: 'page',
						pages: data.totalPages, 
						curr: page,
						skip: true,
						jump: function(obj, first) {
							if(!first) {
								page = obj.curr
								initData(page, keyword)
							}
						}
					});
					
					$("#fanslist").html("")
					
					if(data.rows.length>0){
						$(".nulldata").hide();
						var str="";
						for(var i=0;i<data.rows.length;i++){
							var nick="";
							if((data.rows[i].nickname==null||data.rows[i].nickname=="")&&(data.rows[i].logo==null||data.rows[i].logo=="")){
								nick='<div style="text-align:left;">未授权（id：'+ data.rows[i].id +'）</div>';
							}else{
								if(data.rows[i].logo==null||data.rows[i].logo==""){
									nick='<div class="nickbox"><div id="wlogo" style="background:url(/dvmini/res/images/default_user.png) no-repeat center;-webkit-background-size:contain;background-size:contain;"></div><span class="nick"> '+ data.rows[i].nickname +'</span></div>';
								}else{
									nick='<div class="nickbox"><div id="wlogo" style="background:url('+data.rows[i].logo+') no-repeat center;-webkit-background-size:contain;background-size:contain;"></div><span class="nick"> '+ data.rows[i].nickname +'</span></div>';
								}
							}
							str+='<tr data-id='+ data.rows[i].id +'>'
								+'<td>'+ ((data.page - 1) * data.pageSize + i + 1) +'</td>'
								+'<td style="text-align:left;">'+ nick +'</td>'
								+'<td>'+ data.rows[i].parentfans+'</td>'
								+'<td>'+ data.rows[i].salesname+'</td>'
								+'<td>'+ data.rows[i].miniopenid+'</td>'
								+'<td>'+ toTime_G(data.rows[i].createdtime) +'</td>'
								+'<td>'+ toTime_G(data.rows[i].lastlogintime) +'</td>'
								+'</tr>'
						}
						$("#fanslist").html(str)
						toNull_G();
					}else{
						$(".nulldata").show()
						return false;
					}
					
					
				})
			}
			
			form.on("submit(querybtn)", function(e){
				initData(1, e.field.keyword)
				return false
			})
			
			form.on("submit(resetbtn)", function(e){
				$("[name=keyword]").val("")
				initData(1, "");
				return false
			})
			
			
			function fanstype(t){
				if(t == 1){
					return "销售助手粉丝"
				}else if(t == 2){
					return "万小二粉丝"	
				}else{
					return ""
				}
			}
			
		})
	</script>

</html>